var app = require('koa')();
var router = require('koa-router')();


var Sequelize = require('sequelize');
var sequelize = new Sequelize('postgres://fox:l9yus5nn@localhost:5432/fox');


var User = sequelize.define('user', { firstName: { type: Sequelize.STRING },
lastName: { type: Sequelize.STRING } });


router.get(
  '/users/:id',
  function *(next) {
    console.log(this.params.id);
    this.user =  User.findOne(this.params.id);
    yield next;
  },
  function *(next) {
    console.log(this.user);
    // => { id: 17, name: "Alex" }
  }
);
app.use(router.routes());
app.listen(3000);
